﻿using Magicodes.ExporterAndImporter.Attributes;
using Microsoft.AspNetCore.Mvc;
using System;
using System.Collections.Generic;

namespace MagicodesWebSite.Controllers
{
    [ApiController]
    [Route("api/[controller]")]
    public class MagicodesController : ControllerBase
    {
        [HttpGet("excel")]
        [Magicodes(Type = typeof(ExportTestDataWithAttrs))]
        public List<ExportTestDataWithAttrs> Excel()
        {
            return GenFu.GenFu.ListOf<ExportTestDataWithAttrs>(100);
        }

        [HttpGet("pdf")]
        [Magicodes(Type = typeof(BatchPortraitReceiptInfoInput), TemplatePath = ".//ExportTemplates//batchReceipt.cshtml")]
        public BatchPortraitReceiptInfoInput Pdf()
        {

            var input = new BatchPortraitReceiptInfoInput
            {
                Payee = "湖南心莱信息科技有限公司",
                SealUrl =
                @"",
                LogoUrl =
                @"",
                ReceiptInfoInputs = new List<BatchPortraitReceiptInfoDto>()
            };

            for (var i = 0; i < 500; i++)
                input.ReceiptInfoInputs.Add(new BatchPortraitReceiptInfoDto
                {
                    Amount = 22939.43M,
                    Grade = "2019秋",
                    IdNo = "43062619890622xxxx",
                    Name = "张三",
                    PaymentMethod = "微信支付",
                    Profession = "运动训练",
                    Remark = "学费",
                    TradeStatus = "已完成",
                    TradeTime = DateTime.Now,
                    UppercaseAmount = "贰万贰仟玖佰叁拾玖圆肆角叁分",
                    Code = "1907180000" + i
                });
            return input;
        }


        [HttpGet("Html")]
        [Magicodes(Type = typeof(ReceiptInfo), TemplatePath = ".//ExportTemplates//receipt.cshtml")]
        public ReceiptInfo Html()
        {
            return new ReceiptInfo
            {
                Amount = 22939.43M,
                Grade = "2019秋",
                IdNo = "43062619890622xxxx",
                Name = "张三",
                Payee = "湖南心莱信息科技有限公司",
                PaymentMethod = "微信支付",
                Profession = "运动训练",
                Remark = "学费",
                TradeStatus = "已完成",
                TradeTime = DateTime.Now,
                UppercaseAmount = "贰万贰仟玖佰叁拾玖圆肆角叁分",
                Code = "19071800001"
            };
        }
        [HttpGet("Word")]
        [Magicodes(Type = typeof(ReceiptInfo), TemplatePath = ".//ExportTemplates//receipt.cshtml")]
        public ReceiptInfo Word()
        {
            return new ReceiptInfo
            {
                Amount = 22939.43M,
                Grade = "2019秋",
                IdNo = "43062619890622xxxx",
                Name = "张三",
                Payee = "湖南心莱信息科技有限公司",
                PaymentMethod = "微信支付",
                Profession = "运动训练",
                Remark = "学费",
                TradeStatus = "已完成",
                TradeTime = DateTime.Now,
                UppercaseAmount = "贰万贰仟玖佰叁拾玖圆肆角叁分",
                Code = "19071800001"
            };
        }
    }
}
